package com.example.sandbox.helper;

import com.alibaba.fastjson.JSONObject;
import com.example.sandbox.util.JeepayKit;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class UUPayAuthHelper {

    public String assemblySign(Map<String, Object> paramsMap, String appSecret) {
        try {
            paramsMap.remove("sign");
            // 将 HashMap 转换为 JSONObject
            JSONObject bizReqJSON = new JSONObject(paramsMap);
            // 获取签名
            return JeepayKit.getSign(bizReqJSON, appSecret);
//            // 设置签名到参数 map 中
//            paramsMap.put("sign", sign);
        } catch (Exception e) {
            System.out.println("生成签名字符串时发生错误: " + e.getMessage());
            throw new RuntimeException(e);
        }
    }

}
